#include <iostream>
#include <vector>
#include <ctime>
#include <fstream>

using namespace std;

int main()
{
    unsigned int t_start = clock();
    int i, j, x;
    vector <int> a;
    ifstream fin1("m1_sorted.txt");
    ifstream fin2("m2_reverse.txt");
    ifstream fin3("m3_shuffle.txt");

    while (fin1 >> x) {
        a.push_back(x);
    }

    int n = a.size();

    for (i = 0; i < n - 1; i++){
        for (j = 0; j < n - i - 1; j++){
            if (a[j] > a[j + 1] ){
                x = a[j];
                a[j] = a[j + 1];
                a[j + 1] = x;
            }
        }
    } 

    cout << endl;
    for (i = 0; i < a.size(); i++){
        //cout << a[i] << ' ';
    }

    unsigned int t_finish = clock();
    unsigned int t_work = t_finish - t_start;
    cout << "m1_sorted.txt " << t_work << " milliseconds" << endl;

    a.clear();
    while (fin2 >> x) {
        a.push_back(x);
    }

    n = a.size();

    for (i = 0; i < n - 1; i++){
        for (j = 0; j < n - i - 1; j++){
            if (a[j] > a[j + 1] ){
                x = a[j];
                a[j] = a[j + 1];
                a[j + 1] = x;
            }
        }
    } 

    cout << endl;
    for (i = 0; i < a.size(); i++){
        //cout << a[i] << ' ';
    }

    unsigned int t_finish1 = clock();
    unsigned int t_work1 = t_finish1 - t_start;
    cout << "m2_reverse.txt " << t_work1 << " milliseconds" << endl;

    a.clear();
    while (fin3 >> x) {
        a.push_back(x);
    }

    n = a.size();

    for (i = 0; i < n - 1; i++){
        for (j = 0; j < n - i - 1; j++){
            if (a[j] > a[j + 1] ){
                x = a[j];
                a[j] = a[j + 1];
                a[j + 1] = x;
            }
        }
    } 

    cout << endl;
    for (i = 0; i < a.size(); i++){
        //cout << a[i] << ' ';
    }

    unsigned int t_finish2 = clock();
    unsigned int t_work2 = t_finish2 - t_start;
    cout << "m3_shuffle.txt " << t_work2 << " milliseconds" << endl;

    return 0;
}
